<?php
namespace Home\Model;
use  Think\Model;
class OrderBaseModel extends Model{
protected $autoCheckFields =false;
    /**
     * 记录订单操作记录
     * @access  public
     * @param   string  $order_sn           订单编号
     * @param   integer $order_status       订单状态
     * @param   integer $shipping_status    配送状态
     * @param   integer $pay_status         付款状态
     * @param   string  $note               备注
     * @param   string  $user_id           用户名ID，用户自己的操作则为 buyer
     * @return  void
     */
    public function order_action($order_sn, $order_status, $shipping_status, $pay_status, $note = '', $user_id = null, $place = 0) {


        $username=M('users')->where("user_id='$user_id'")->getField('user_name');
        if (is_null($username)) {
            if($user_id)$username =$user_id; //传的是用户名
            else $username ='异常用户';
        }


        $sql = 'INSERT INTO ' .C('DB_PREFIX'). 'order_action (order_id, action_user, order_status, shipping_status, pay_status, action_place, action_note, log_time) ' .
                " SELECT order_id, '$username', '$order_status', '$shipping_status', '$pay_status', '$place', '$note', '" . gmtime() . "' " .
                'FROM ' . C('DB_PREFIX') . "order_info WHERE order_sn = '$order_sn'";
        M()->execute($sql);
    }

        /**
     * 记录订单操作记录
     **/
     public function add_error($note)
     {
        $data['info']=$note;
        $data['time']=gmtime();
        M('error_log')->add($data);
     }    

}
?>
